package Level02;

import org.omg.CORBA.MARSHAL;

import java.util.Calendar;
import java.util.Date;

public class One {
    public static void main(String[] args) {
        //计算你活了多少天
        Calendar calendar = Calendar.getInstance();
        Date date = new Date();

        calendar.set(2002, 12, 25);
        Date time = calendar.getTime();
        //把时间转化为毫秒值
        long time1 = time.getTime();
        //获取当前时间
        long now = System.currentTimeMillis();
        //计算时间差
        long millis = (now - time1);
        System.out.println("活了"+millis/1000+"秒");
        //计算天数
        long day = millis / (1000 * 60 * 60 * 24);
        System.out.println("活了"+day+"天");

//        Calendar calendar = Calendar.getInstance();
//        Date time = calendar.getTime();
//        calendar.set(2002, 12, 25);
//        Date time1 = calendar.getTime();
//        long day = (time.getTime() - time1.getTime()) / (1000 * 60 * 60 * 24);
//        System.out.println("活了"+day);
    }

}
